+ 3

Can we access the special point of something?

I have a database that stores time in this format: year/month/day/hour/minute Can I access just to the hour part?

11th Nov 2019, 4:31 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
9 ответов
+ 1
Maybe you can try to use HOUR function. See this SQL date functions reference: https://www.tutorialspoint.com/sql/sql-date-functions.htm
11th Nov 2019, 4:45 PM
Ipang
+ 3
Thanks a lot Ipang
11th Nov 2019, 4:53 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
+ 3
If I wanna get for example day of the date, should I store day in a seperate column or I can have access to it from the format I mentioned above?
12th Nov 2019, 12:15 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
+ 3
Yes I got that but if I wanna use your solution,do I have to store day and month in two separate columns?
12th Nov 2019, 1:16 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
+ 3
Thank you very much I got the point completely
12th Nov 2019, 1:24 PM
Nika Soltani Tehrani
Nika Soltani Tehrani - avatar
+ 2
You're welcome Nika Soltani Tehrani
11th Nov 2019, 5:04 PM
Ipang
+ 1
For day in a month use DAYOFMONTH. For day in a week use DAYOFWEEK. Refer to the link on my previous comment for syntax and example.
12th Nov 2019, 1:14 PM
Ipang
+ 1
No, I think you don't necessarily need two columns to separate day and month. Those date functions are there for this reason, so we can extract a particular part of DATE or DATETIME column (if I understood it correctly).
12th Nov 2019, 1:21 PM
Ipang
+ 1
You're very welcome Nika, I'm glad you got it 👍
12th Nov 2019, 1:25 PM
Ipang