To All
How can I convert date() to a datetime field in MS Sql server .. I was given this formula and it does work but does not insert the correct
date into the date portion of the field ..
nDateTime := ( DATE() - CTOD("") )+( SECONDS()/ (24*3600)) equals
something like 6/19/8620 5:17:14 PM
As you can see .. todays date is 05/22/2008 5:17 PM ..
I have records sorted by date desc and SQL server does not take into account natural order .. when you insert DATE() into a datetime field you get 5/22/2008 12:00 PM .. and if you have two rows with the same date .. I can not descriminate the time since both have the same 'default' time.. I need to be able to insert the date and time into the datetime fields to make the rows sort correctly.
Any advice or help would be appreciated BIG-TIME !!
Rick Lipkin
SC Dept of Health, USA
ADO Date time update SQL Server
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- Eugeniusz Owsiak
- Posts: 60
- Joined: Fri Oct 07, 2005 5:38 am
- Location: Poland
Rick,
This update work for me and i get a proper datetime value in table.
Maby I don't understand your problem. If so - sorry.
Regards Eugeniusz
Code: Select all
set date american
set century on
...
oRs:Source := "Update <your table> set <your datetime field> = '"+;
dtoc(date())+" "+time()+"' where ......"
...
oRs:Open()
Maby I don't understand your problem. If so - sorry.
Regards Eugeniusz
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact: