Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
josephinetedesc
Creator III
Creator III

Today as default when page loads

Hi

I am trying to set the default for a page - I want the default date to appear in the Calendar:

I have tried setting a variable called vMyDate = Today()

I have then gone to the page and tried to get the Calendar object to display today's date and therefore the chart would update to show today's values.

I have also tried making a button and using the trigger to set the date  - (I think i remember something about dates being treated as strings???)

Complication:  The calendar object reflects the field Appt_DtTm (this is decimal and shows date and time).  I need the date and time reflected in the chart - see graphic

=time(App_DtTm,'HH:MM')

anyhelp gratefully appreciated.

jo


13 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Its not a good idea to store date and time in the same field - this is due to the high cardinality of timestamps. You will get better performance by splitting it into date and time and rounding the time to the smallest duration of intersest.

     To get separate fields

     LOAD ...

          Date(Floor(Appt_DtTm)) As Appt_Dt,

         Time(Round(Frac(Appt_DtTm), 1/24) As Appt_Time   // to the nearest hour

This assumes that the Appt_DtTm is recognised as a time stamp.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
josephinetedesc
Creator III
Creator III
Author

But I need the chart respond to the Appt_Time and the Appt_Dt ...

jonathandienst
Partner - Champion III
Partner - Champion III

Date/time values are stored in units of day, so the date is the integer part of the date (Floor()) and the time is the fractional part (Frac()). 24 hours is 1 day, so one hour is the value 1/24, one minute is 1/24/60 (=1/1440) and one second is 1/24/60/60 (=1/86400). So to round time to the nearest hour we say Round(Frac(Appt_DtTm), 1/24) and to display that as a time value, we format it with Time  - Time(Round(Frac(Appt_DtTm), 1/24)).

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Josephine Tedesco wrote:

But I need the chart respond to the Appt_Time and the Appt_Dt ...

Is the Appt_DtTm currently linked to the fact values in the chart? The code fragment I gave earlier should be part of the LOAD where you are currently loading Appt_DtTm - but instead of loading Appt_DtTm, you are loading Appt_Dt and Appt_Tm as two fields instead of one.

Then you can make selections on either field or use them as dimensions...

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
josephinetedesc
Creator III
Creator III
Author

yes I understand that ... but I am trying to get the chart to show what occurred hourly on a particular day - so my chart dimension is

 

=time(App_DtTm,'HH:MM')

so the calendar treate the App_DtTm as a day but the chart actually shows what occurred on that day but by the hour/time

jonathandienst
Partner - Champion III
Partner - Champion III

The problem is Time() does not change the underlying value, so you will be getting different values that look the same, but are not. That's why you need to use the Floor() and Round(Frac()) calculations.

For example, a timestamp of 2015/08/27 07:33:15.01563 will display as 7:33, but so will 2013/12/11 07:33:22.565 and 2015/08/27 07:06:01.0001 -- despite the fact the Time() makes them look the same, they will all have different values.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Josephine Tedesco wrote:

yes I understand that ... but I am trying to get the chart to show what occurred hourly on a particular day -

And if you use the code i gave you, the time field will be in hours, so all the transactions that happen in that hour will get the same time value and you can use that as a chart dimension in hours.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
josephinetedesc
Creator III
Creator III
Author


but that is why i want to ensure that the date is Today(2) - therefore the fraction part will always be different.

josephinetedesc
Creator III
Creator III
Author

ok - I see that - but that is a different question (probably for another day when I start checking what it is exactly that is wanted - probably better than what I am doing actually) For now though  I just want to be able to set the date to Today(2) when I open up that page