question

Jramos avatar image
0 Votes"
Jramos asked AryaDing-MSFT edited

How can I remove the time with the date of the database in the data retrieval

How can I remove the time with the date on a datePicker on sql server c #. Example ddMMYYY 00:00:00

sql-server-generalwindows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
1 Vote"
Viorel-1 answered

Try this binding:

 <TextBlock Text="{x:Bind DuoDate.ToShortDateString()}" ... 



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GuoxiongYuan-7218 avatar image
0 Votes"
GuoxiongYuan-7218 answered Jramos commented

Try to use Format function:

 SELECT FORMAT(GETDATE(), 'ddMMyyyy');
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This select cast goes in the sql set-up

0 Votes 0 ·
YitzhakKhabinsky-0887 avatar image
0 Votes"
YitzhakKhabinsky-0887 answered

Another way is via CASTing:

  SELECT CAST(GETDATE() AS DATE);
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered

on a datePicker on sql server

There is not DatePicker or any other control on SQL Server side.

Use DateTime.Date Property to get the date without time potion.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered AryaDing-MSFT edited

If you never need the time, then use a date column instead of datetime in SQL.

· 10
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have on the table date problem this in the part of receiving data.

  cmd.Parameters.Add("@duoDate", SqlDbType.Date).Value = DateNac.SelectedDate.Value.Date;

the problem i s here :
pettable.DuoDate = reader.GetDateTime(1);





0 Votes 0 ·

@Jramos Could you please provide us the error message?

0 Votes 0 ·

the problem is: when displaying the data in the recovery I get the date and time I want to remove the time when displaying the data.

0 Votes 0 ·
Show more comments

Maybe you should execute 'pettable.DuoDate = reader.GetDateTime(1).Date'?


0 Votes 0 ·

I have it : pettable.DuoDate = reader.GetDataTime(1).Date;

but when displaying the data I get the date (which is chosen in the DataaPicker) and the time

0 Votes 0 ·
Show more comments
AryaDing-MSFT avatar image
0 Votes"
AryaDing-MSFT answered

Hi,

Welcome to Microsoft Q&A!

I don’t understand your meaning well. You means that you have inserted an value that seleced through DatePicker(UWP control) into SQL database, and now you want to remove the value from database, right? If yes, please refer to the following code.

 using (var cmd = connection.CreateCommand())
     {
         connection.Open();
         cmd.CommandText = "delete from tableName where columnName = @date";
         cmd.Parameters.AddWithValue("@date", date);
         cmd.ExecuteNonQuery();
     }



If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.