Hi
I want to get data whose time is 72 Hrs later from current Date. I have data like below.
FromDate FromTime
2022-09-11 09:00:00.0000000
2022-09-06 13:00:00.0000000
2022-10-08 08:45:00.0000000
2022-10-20 08:00:00.0000000
Thanks
Hi
I want to get data whose time is 72 Hrs later from current Date. I have data like below.
FromDate FromTime
2022-09-11 09:00:00.0000000
2022-09-06 13:00:00.0000000
2022-10-08 08:45:00.0000000
2022-10-20 08:00:00.0000000
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Mar 3, 2023, 10:48 AM
Hi Ramco,
To get the data whose time is 72 hours (3 days) later from the current date, you can use the following SQL query:
This query adds 72 hours to the FromDate and FromTime columns to get a future date and time, and then compares it to the current date using the GETDATE() function. The DATEADD function is used to add hours to the combined FromDate and FromTime columns, and the CONCAT function is used to combine the two columns into a single datetime value. Make sure to replace your_table_name with the actual name of your table.
Hope this helps.
Rajeev KumarPosted Mar 3, 2023, 9:57 AM
Nitin SontakkePosted Oct 6, 2022, 2:52 AM
Hello,
You want database side solution (which database?) or programming language (which language?) solution.
Is this infornation stored in two separate columns / variables? If yes, you will have to first combine them together to form a datetime variable for sure.
On Microsoft SQL Server side you have dateadd function which takes several arguments, hours being one of them.
On Microsoft .NET side, the datetime structure has .AddHours method which returns new datetime structure.
Hope it helps!