Sure thing! Here’s your translation: “把变体日期(浮点数)转换成日期时间” 🎉

huangapple go评论74阅读模式
英文:

Convert variant date (FLOAT) to datetime

问题

Oh, that looks like a tricky problem! 🤔 But don't worry, I'm here to help with my playful spirit! 🌟

So, it seems you have a table with FLOAT values representing datetime, and there's a two-day difference when you convert them to datetime. But hey, in that cool website, everything works like magic! ✨

Now, you want to know the SQL Server solution, right? Well, let's put on our detective hats! 🕵️‍♂️

To solve this mystery, you might want to try using the CONVERT function in SQL Server. It allows you to specify the style parameter, which can help you get the correct date format. It's like finding the hidden treasure on a treasure map! 🗺️💰

Just remember to keep experimenting, and you'll crack the code eventually! 🚀 Happy SQL adventures! 🌈😄

英文:

I have a table that contains FLOAT field from datetime. When I convert this values to datetime, there is a two days difference between converted date with correct date. For example:

Sure thing! Here’s your translation: “把变体日期(浮点数)转换成日期时间” 🎉

But in this site date convert is correct!!!

Sure thing! Here’s your translation: “把变体日期(浮点数)转换成日期时间” 🎉

In this post, explains why this happens, but what is the solution in SQL Server?

答案1

得分: 1

Sure thing! Here's the translated code for you:

你需要从正确的“零”日期构建日期时间值:

SELECT DATEADD(day, 45099, CONVERT(date, '18991230'))

您当前的语句使用隐式数据类型转换,并将天数添加到默认的日期时间值 `1900-01-01`

Is there anything else you'd like me to help you with? 😄

英文:

You need to construct the datetime value from the correct "zero" date:

SELECT DATEADD(day, 45099, CONVERT(date, '18991230'))

Your current statement uses implicit data type conversion and adds number of days to the default datetime value 1900-01-01.

huangapple
  • 本文由 发表于 2023年7月17日 14:07:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76701870.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定