Date Comparisions - Differing formats
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Date Comparisions - Differing formats Expand / Collapse
Author
Message
Posted 5/26/2006 7:26:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/1/2006 12:25:00 PM
Posts: 3, Visits: 1
My database uses the date format yyyy-mm-dd. I have a new data source that uses yyyymm for a key date. How can I compare the two? I need to essentially do this:
where
yyyymm between yyyy-mm-dd1 and yyyy-mm-dd2

Post #4256
Posted 5/26/2006 12:13:31 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 11/5/2009 4:40:02 PM
Posts: 717, Visits: 466
Just specify a matching format, if the day is missing it will be replaced by the 1st.

where '200605' (date, format 'yyyymm') between date1 and date2

Dieter


Post #4261
Posted 5/26/2006 2:07:27 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/1/2006 12:25:00 PM
Posts: 3, Visits: 1
thanks!
Post #4263
Posted 6/1/2006 12:32:45 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/1/2006 12:25:00 PM
Posts: 3, Visits: 1
I'm not getting results back from this.

SELECT SOURCE_MONTHYEAR
WHERE
SOURCE_MONTHYEAR (date, format 'yyyy/mm/dd') BETWEEN
VARIABLE1
AND VARIABLE2


VARIABLE1 and VARIABLE2 are date format YYYY/MM/DD
SOURCE_MONTHYEAR is date format YYYYMM


I did get results using substring and concatenation on the between variables, i.e.: SUBSTR(VARIABLE1,1,4) || SUBSTR(VARIABLE1,5,2)

I've tried using date, format yyyymm on the between variables as well with empty results.

What else can I try?

Thanks in advance
Post #4294
Posted 6/2/2006 3:51:42 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: PAC and SFT Members
Last Login: 9/9/2009 4:34:06 PM
Posts: 407, Visits: 889
I think you are confusing external and internal representation. Is SOURCE_MONTHYEAR actually defined as DATE or is it CHAR that you know is supposed to represent a YYYYMM format date? The FORMAT specification is used for the conversion between external (character string) and internal datatypes (such as DATE). If you aren't doing conversion to/from character, FORMAT isn't relevant.

If SOURCE_MONTHYEAR is a character string, try it the way Dieter suggested.

On the other hand, if VARIABLE1 and VARIABLE2 are actually character strings you'd want to CAST those.

In either case, the FORMAT describes the character string - not the comparison.
Post #4298
Posted 6/2/2006 3:51:54 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: PAC and SFT Members
Last Login: 9/9/2009 4:34:06 PM
Posts: 407, Visits: 889
I think you are confusing external and internal representation. Is SOURCE_MONTHYEAR actually defined as DATE or is it CHAR that you know is supposed to represent a YYYYMM format date? The FORMAT specification is used for the conversion between external (character string) and internal datatypes (such as DATE). If you aren't doing conversion to/from character, FORMAT isn't relevant.

If SOURCE_MONTHYEAR is a character string, try it the way Dieter suggested.

On the other hand, if VARIABLE1 and VARIABLE2 are actually character strings you'd want to CAST those.

In either case, the FORMAT describes the character string - not the comparison.
Post #4299
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 8:00pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.078. 7 queries. Compression Disabled.