How to Show date in textbox which type is date in asp.net - sql

How to Show date in textbox from database.TextBox type is "date". In asp.net

As the experts said above, this one worked for me:
((DateTime)dr["columnName"]).ToString("yyyy-MM-dd")
or
Convert.ToDateTime(dr["columnName"]).ToString("yyyy-MM-dd");
Try to re-format the date in the parentheses, it may be (yyyy-MM-dd) or (dd-MM-yyyy)
This one is working in 2023.
NOTE: I'm fetching the data from the database in a DataRow instead of DataTable, NOT because it works better, but because this is what I need.

You need to convert the value to a datetime, then convert again to string.
Something like this:
_txtCoatOrderDate.Text = ((Datetime)dt.Rows[i]["Coat_CUSTM_Date"]).ToString("dd/MM/yyyy");

Try this-
_txtCoatOrderDate.Text = Convert.ToDateTime(dt.Rows[i]["Coat_CUSTM_Date"]).ToString("dd/MM/yyyy");

i tried this its working
TextBox1.Text = ((DateTime)ds.Tables[0].Rows[0]["Coat_CUSTM_Date"]).ToString("yyyy-MM-dd");
Thanks RMH Sir

Related

WHERE Condition in the Kentico repeater

I have a list of events that are shown on "Events" page using a repeater. Each event is a page type and has a field "EventStartDateTime". I want to show only those events where the event start date is >= today. For now in the WHERE field in repeater,i am using the following condition:
(EventStartDateTime >= '{% DateTime.Now #%}') OR (EventStartDateTime = '')
But no data is visible on the page. So is it right ?
Any help will be greatly appreciated. Thanks
I checked your code and it's kinda worked for me, but I will still modify it like this:
(EventStartDateTime >= GetDATE()) OR (EventStartDateTime IS NULL)
Because second part where you compare 'Date and time' field with empty string is not correct. So in your case, you don't get any data if 'EventStartDateTime' is not populated for every item. If that is not the case, you should try remove WHERE condition and check if you get data without it.
Best regards,
Dragoljub
Your statement will work with a macro like so:
(EventStartDateTime >= '{% CurrentDateTime.ToShortDateString() %}')
Your second condition would not work because your EventStartDateTime field is (assumed) to be a DateTime object so checking for an empty string will not work. You need to check for NULL.

MS SQL Server - convert(datetime, string, code) -> What code for dd/mm/yyyy hh:mm:ss (24hours)?

I would to CONVERT this string 08/12/2014 16:46:12 to a datetime but I do not know what code to use and it is driving me crazy. I looked on many pages but do not find it
CONVERT(datetime,'08/12/2014 16:46:12',???)
Thank you in advance
Parameter 131 is incorrect, because it uses the Hijri calendar - 2014 becomes 2576.
Use 103 as style parameter instead:
convert(datetime,'08/12/2014 16:46:12',103)
Despite the documentation on http://www.w3schools.com/sql/func_convert.asp it also converts the time value (tested on SQL Server 2014 and 2008 Express).
convert(datetime,'08/12/2014 16:46:12',13)
OR
convert(datetime,'08/12/2014 16:46:12',113)
One Last GO :)
SELECT CONCAT ((convert(datetime,'08/12/2014,103)),' ',(convert(datetime,'16:46:12',114))) AS DateTime
Here is a list of them all http://www.w3schools.com/sql/func_convert.asp

In SSRS how can I filter using a StartDate parameter where the format does not include AM or PM

I am trying to use a Start Date parameter in a tablix filter. The problem is the incoming data is in the following format, 6/06/2013 6:00:00, and does not include AM or PM - which is causing the filter not to work properly.
Any suggestions? Thanks in advance
If you speak about AX:
You can use this function:
=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, Fields!StartDate, "t", Parameters!AX_RenderingCulture.Value)
Fields!StartDate is your DATE field
i never use "t", if it doesn't work try "tt", it will return if your time is "AM" or "PM"

Getting view options in Microsoft Project using VBA

If I want to change the current date format to 20, for example, I can use the command
OptionsViewEx DateFormat:=20
but how can I get the current date format (or any other view option for that matter)?
DefaultDateFormat should be the function to use.
oldvalue = Application.DefaultDateFormat
Application.DefaultDateFormat = 20 ' or = pjDate_mm_dd_yyyy
This gets or sets the default date format. (technet)
This gives the complete list of format types.
If you use Date function get a date in current format, but if you need change use format(Date,"yyyy-mmmm-dd") for example.

Access SQL for sorting by date with TempVars

im trying to make a query from the use of TempVars
im Using SQL to run the query but every time i try, it return Invalid date value
this is the line that will not work
this returns error
WHERE ((([Table].[Issue Date])>=#[TempVars]![tmpDateFrom]# And ([Table].[Issue Date])>=#[TempVars]![tmpDateTo]#));
this returns fine
WHERE ((([Table].[Issue Date])>=#10/12/12# And ([Table].[Issue Date])>=#11/12/12#));
I have checked the TempVars [tmpDateFrom] and [tmpDateTo] and they out put the date value i need.
Please help
Thank you all or the help.
due to the requirement of the database #Nicarus had the right answer this is the solution for those still wondering.
WHERE ((([Table].[Issue Date])>=[TempVars]![tmpDateFrom] And ([Table].[Issue Date])>=[TempVars]![tmpDateTo]));