I am working with a database structure that I can not change - there are two fields in the SQL Server 2005 environment - A complete date time zone and a HHMM field.
The software application does not always populate both fields, so I need to create a complete date-time field. If the second-minute hour-minute field hours are zero, then I will have to make a complete date-time from the date part of the date zone, hour of HHMM area, minute of HHMM. Field and zero seconds.
How can I do this?
All these update time-by-time values over time, with the HHMM Date time with date:
updateable sit dateTime = DateTime + STUFF (HHMM, 3, 0, ':') where datetime = DATEAD (day, DATEDIFF (day, 0, Date time), 0) It is believed that HHMM column is a string of a certain format, i.e. you always have 2-digit hours in HHMM And are 2-digit minutes, such as '1400' or '0825 '. The query includes : adds the date-time column value between the time parts and the resulting time (represented as string).
If HHMM is an integer, it may be zero or zero leading to the bar such as 08:00 or 00:05 (Which will be stored, respectively as 800 and 5 ) Therefore, before incorporating the colon, we will need to bring the values in the formatted string as the HHMM , e.g.
We can now pass this expression in the above query:
Unstable SAT DateTime = DateTime + Stuff (Wright (10000 + HHMM, 4), 3, 0, ':') where datetime = DATEADD (day, DATEDIFF (day, 0, datetime), 0)
Comments
Post a Comment