View previous topic :: View next topic
|
Author |
Message |
Shaheen Shaik
New User
Joined: 05 May 2016 Posts: 13 Location: India
|
|
|
|
Please help me out for the below query,
Can we use SUBSTR for date functions in DB2 ? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Do you mean some entity called "SUBSTR for date functions" or use SUBSTR instead of date functions or use SUBSTR on the value returned by date functions ie can a date function be the first patrameter to SUBSTR?
What have you tried? |
|
Back to top |
|
|
Shaheen Shaik
New User
Joined: 05 May 2016 Posts: 13 Location: India
|
|
|
|
Thanks for your response Nic.
Let me make my query clear.
My question is that can we use SUBSTR function to the column which holds the date in DB2 table?
ex: Select SUBSTR(join_date,1,10) from employee table
join_date has data type as DATE in the employee table
Please let me know that whether SUBSTR function is applicable for VAR/CAHR only otherwise can we use it for DATE functions as well. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
You already have date functions like:
- DAY(mydatefield)
- MONTH(mydatefield)
- YEAR(mydatefield)
What more do you need ??
Note: if SUBSTR(join_date,1,10) worked, it would return the 10 first chars of the date, which is... the date itself. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Quote: |
Please let me know that whether SUBSTR function is applicable for VAR/CAHR only otherwise can we use it for DATE functions as well. |
No, unless you add CHAR on date. as Marso said why do you need that anyways? Any interview question? |
|
Back to top |
|
|
|