![]() ![]() If it's in the range, subtract 5 hours from the date, otherwise subtract 6 hours. Time) and compares the given date to that range. It finds the Daylight Savings Time range (based on the National Standards Bureau for Central This will accept a datetime value, and makes the assumption that the value is in UTC time. Granted, it only fits my particular need. How do I turn this logic into a SQL function? NOW.here's where you T-SQL gurus come in. It simply uses the difference between GETUTCDATE and GETDATE (my server is in Central time zone) and uses that difference in seconds to subtract from the given date/time value. I found a SQL function that does all that. (Can you tell I'm more comfortable in VBA than in SQL?) When I run queries where the criteria includes any of these date/time fields I want to apply Central Time. If given Date/Time value >= DSTBegins AND Date/Time value < DSTEnds ThenĬentral Time value = Give Date/Time value - SubractInt Get 1st Sunday of November for the year of the given Date/Time value and call it DSTEnds Get 2nd Sunday of March for the year of the given Date/Time value and call it DSTBegins It simply compares the given date/time value to the national standard for Daylight Savings Time (Currently 2nd Sunday of March atĢ AM to 1st Sunday of November, 2 AM) and adjusts the date accordingly. SO.(sorry, had to get that out of the way first).I decided to write a simple function that does not rely on system time. In December the difference between UTC and Central Time is 6 hours, not five. However, it does not consider whether the date/time that I am feeding it is in Daylight Savings It simply uses the differenceīetween GETUTCDATE and GETDATE (my server is in Central time zone) and uses that difference in seconds to subtract from the given date/time value. ![]() ![]() When I run queries where the criteria includes any of these date/time fields I want to apply Central Time. I have date/time values in a database that are in UTC. So I guess I need a little hand holding from someone who's done this andĬan vouch for my logic, and also answer a question or two. However, when it comes to discussions of space and time, I'm no Einstein. Master Class How to Spin the Straw of Life into Literary Gold with Signe Hammer JAN 24, 26 & 28 1PM CST 250.00 Add to cart Raising the Spiced Cup: Poetry on GodFire Write with Spirit with Judyth Hill JAN 19 6PM CST 80.00 Add to cart Silent Write: JANAPR 2022 0.00 50. I have a specific example regarding an issue for which there is plenty of general advice on the Internets. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |