Insert Date and time in sql server 2008
-
Hi,I am salman. I have 2 separate fields in sql server 2008 for date and time. one field is of type date and the other is time. In .net we have DateTime object but no separate objects for date and time so how to insert date and time in sql server 2008 through c#.net code? remember i can not insert string of date and time coz the data types in database are date,time not string. Best Regards, Salman Farrukh
-
Hi,I am salman. I have 2 separate fields in sql server 2008 for date and time. one field is of type date and the other is time. In .net we have DateTime object but no separate objects for date and time so how to insert date and time in sql server 2008 through c#.net code? remember i can not insert string of date and time coz the data types in database are date,time not string. Best Regards, Salman Farrukh
-
Hi,I am salman. I have 2 separate fields in sql server 2008 for date and time. one field is of type date and the other is time. In .net we have DateTime object but no separate objects for date and time so how to insert date and time in sql server 2008 through c#.net code? remember i can not insert string of date and time coz the data types in database are date,time not string. Best Regards, Salman Farrukh
yes like sarang_k says!!! you only have to concat both values of date and time like a string and after
Convert.ToDateTime(yourConcatString);
and save it
-
Hi,I am salman. I have 2 separate fields in sql server 2008 for date and time. one field is of type date and the other is time. In .net we have DateTime object but no separate objects for date and time so how to insert date and time in sql server 2008 through c#.net code? remember i can not insert string of date and time coz the data types in database are date,time not string. Best Regards, Salman Farrukh
Do want to create two fields date & time?
-
Do want to create two fields date & time?
look in sql server 2008 we have three data types datetime,date,time. I want to store date in date field and time in time field.but not in datatime field.
-
Hi,I am salman. I have 2 separate fields in sql server 2008 for date and time. one field is of type date and the other is time. In .net we have DateTime object but no separate objects for date and time so how to insert date and time in sql server 2008 through c#.net code? remember i can not insert string of date and time coz the data types in database are date,time not string. Best Regards, Salman Farrukh
i think this code helps you..... SELECT CAST('2007-05-08 12:35:29. 1234567 +12:15' AS time(7)) AS 'time' ,CAST('2007-05-08 12:35:29. 1234567 +12:15' AS date) AS 'date'; the output of this code is- Time 12:35:29. 1234567 Date 2007-05-08