This topic is locked

DateTime.Now.Date.ToString()

7/15/2007 1:30:27 AM
ASPRunner.NET General questions
T
thecomputerguy author

Hello when I set a datetime field with DateTime.Now.Date.ToString()

to store datetime in a datetime field in SQL 2005 the record is saved but is does not save the time stamp on it just the DATE.
I have search the web and there is been an issue with this and wanted to know if you all have a suggestion?
[codebox]

e.Command.Parameters("@dUpdateDate").Value = DateTime.Now.Date.ToString()

[/codebox]
SQL field is set up as:

dUpdateDate datetime
Results:

dUpdateDate = 7/15/2007 12:00:00 AM stored inthe database even though it was saved at 12:28 AM
I foundthis site that talk about this issue also:

Issue is also talked here

T
thecomputerguy author 7/15/2007

Hello when I set a datetime field with DateTime.Now.Date.ToString()

to store datetime in a datetime field in SQL 2005 the record is saved but is does not save the time stamp on it just the DATE.
I have search the web and there is been an issue with this and wanted to know if you all have a suggestion?
[codebox]

e.Command.Parameters("@dUpdateDate").Value = DateTime.Now.Date.ToString()

[/codebox]
SQL field is set up as:

dUpdateDate datetime
Results:

dUpdateDate = 7/15/2007 12:00:00 AM stored inthe database even though it was saved at 12:28 AM
I foundthis site that talk about this issue also:

Issue is also talked here


Full thread

T
thecomputerguy author 7/15/2007

I was curious so I run a trace on the SQL server and noticed tha the Time is not getting passed to the SQL

here is the actual value

@dUpdateDate=''2007-07-15 00:00:00:000''
So this tells me that I either the .Net framework during update it does nto convertit correctly or the before EDIT event there is soemthing happening.
this is not an issue during ADD as the date is preset on the Record level as default Getdate().
Please Help.
Andrew

Eugene 7/16/2007

All that you need is to set up "view as" as Datetime and "edit as" as simple edit box with datepicker + show time in datepicker at formatting page.

You will get something like this:
[codebox]if (fldOrderDate != null && fldOrderDate.Text != string.Empty) e.NewValues["OrderDate"] = func.str2date(fldOrderDate.Text, "dd.MM.yyyy HH:mm:ss");[/codebox]