Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
anuradhaa
Partner - Creator II
Partner - Creator II

Dealing with two dates

I have below two dates and they are in two different tables, I want to use common date.

Than i use master calander as belwo,

[TempCalendar]:

LOAD DISTINCT

    DATE,   

  Year(DATE) as Year,

  Month(DATE) as Month,

  'Q' & Ceil(Month(DATE)/3) as AQuarter

  RESIDENT ABC_DATA;

join

LOAD DISTINCT

  DATE,

  Year(DATE) as Year,

  Month(DATE) as Month,

  'Q' & Ceil(Month(DATE)/3) as Quarter

RESIDENT Charges;

MainCalendar:

load DATE,

  Year,

  Month,

  Quarter

  Resident TempCalendar;

Here i remane ABC_DATE and XYZ_DATE when i lod that table.

But when i look at the table year,Month is missing in some recrds.

Please help

ABC_DATEXYZ_DATE
5/30/2014 8:451/18/2014 23:50
5/30/2014 8:453/25/2014 3:25
5/30/2014 8:453/28/2014 10:11
5/30/2014 8:454/2/2014 13:46
5/30/2014 8:454/4/2014 9:45
5/30/2014 8:454/14/2014 10:04
5/30/2014 8:454/15/2014 3:00
5/30/2014 8:454/15/2014 6:20
5/30/2014 8:454/18/2014 8:49
5/30/2014 8:454/18/2014 21:05
5/30/2014 8:454/21/2014 13:46
5/30/2014 8:454/26/2014 6:25
5/30/2014 8:454/28/2014 10:30
5/30/2014 8:455/5/2014 9:57
5/30/2014 8:455/8/2014 1:20
5/30/2014 8:455/10/2014 1:20
5/30/2014 8:455/12/2014 10:37
1 Solution

Accepted Solutions
saikatghosh
Contributor III
Contributor III

istead of join concate two table and convert the date into proper date format by using floor

ie  Date(floor(Date)) as Date

Table1:

Load

Date(Floor(DATE) as DATE

Resident ABC_DATA;

Concatenate(Table1)

Load

Date(Floor(DATE) as DATE

Resident Charges;

Master_Calendar:

Load

DATE,

Year(DATE) as YEAR,

Month(DATE) as MONTH

Resident Master_Calendar;

View solution in original post

11 Replies
alexandros17
Partner - Champion III
Partner - Champion III

In your main calendar you are referencing quarter (in the TempCalendar you called it AQuarter)

rename AQuarter in quarter and reload.

Let me know

anuradhaa
Partner - Creator II
Partner - Creator II
Author

Thank You Alessandro,

But that is not the issue here. DAte is there in all raw, but year and moths are missing in some records

alexandros17
Partner - Champion III
Partner - Champion III

It is normal with a Join (outer) because you are taking sets of data from both tables and if a date (so year and month) is present in  a table and not in the other you will see dates but missing year and month for that date.

Anonymous
Not applicable

Anuradha,

Try concatenating instead of join.

[TempCalendar]:

LOAD DISTINCT

    DATE

RESIDENT ABC_DATA;

concatenate (TempCalendar)

LOAD DISTINCT

  DATE

RESIDENT Charges;

MainCalendar:

noconcatenate

load distinct DATE,

  Year(DATE) as Year,

  Month(DATE) as Month,

  'Q' & ceil(month(DATE)/3) as Quarter

Resident TempCalendar;

drop table TempCalendar;

You could also only load distinct once in main calendar as an alternative instead of both times in tempcalendar.

anuradhaa
Partner - Creator II
Partner - Creator II
Author

The problem is i have two date formats,

5/30/2014  8:45:00 AM and   3/25/2014  3:25:00 AM. So is it a problem here?

Anonymous
Not applicable

looks like the same format to me

marcus_malinow
Partner - Specialist III
Partner - Specialist III

I'd suggest that in addition to concatenation, you change your dates in your source tables to date format rather than timestamps. If you are  working with a lot of data this will result in a far smaller calendar table.

anuradhaa
Partner - Creator II
Partner - Creator II
Author

sorry  my two date formats are

2014-06-27 14:01 and 07-18-2014 07:10

saikatghosh
Contributor III
Contributor III

istead of join concate two table and convert the date into proper date format by using floor

ie  Date(floor(Date)) as Date

Table1:

Load

Date(Floor(DATE) as DATE

Resident ABC_DATA;

Concatenate(Table1)

Load

Date(Floor(DATE) as DATE

Resident Charges;

Master_Calendar:

Load

DATE,

Year(DATE) as YEAR,

Month(DATE) as MONTH

Resident Master_Calendar;