Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SUBSTR for Date functions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Shaheen Shaik

New User


Joined: 05 May 2016
Posts: 13
Location: India

PostPosted: Thu Apr 06, 2017 2:14 pm    Post subject: SUBSTR for Date functions
Reply with quote

Please help me out for the below query,
Can we use SUBSTR for date functions in DB2 ?
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2230
Location: Hampshire, UK

PostPosted: Thu Apr 06, 2017 2:28 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Shaheen Shaik

New User


Joined: 05 May 2016
Posts: 13
Location: India

PostPosted: Thu Apr 06, 2017 3:04 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1329
Location: Israel

PostPosted: Thu Apr 06, 2017 6:47 pm    Post subject: Reply to: SUBSTR for Date functions
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2260
Location: NY,USA

PostPosted: Fri Apr 07, 2017 1:53 am    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Mainframe datasets without any last r... rajatbagga All Other Mainframe Topics 1 Tue Sep 24, 2019 8:47 am
No new posts Date insertion returns -180 Raghu navaikulam CICS 1 Mon Jul 29, 2019 5:12 pm
This topic is locked: you cannot edit posts or make replies. Need to write the date at the end of ... Poha Eater DFSORT/ICETOOL 16 Tue Jul 23, 2019 2:33 pm
No new posts SQL to retrieve latest Eff date and then vinu78 DB2 8 Tue Apr 30, 2019 3:45 pm
No new posts how to add date & timestamp to th... dharmaraok DFSORT/ICETOOL 5 Thu Apr 18, 2019 2:45 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us