Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

DatePart question

Explorer ,
Dec 23, 2008 Dec 23, 2008
I am trying to do a datepart on a time datatype field in a mysql db and having some problems displaying the hour. For a simple explanation of what I am trying is this:
#DatePart("h", getLastedit.eventstarttime)#
This gives:
Parameter validation error for the DATEPART function.
The value of parameter 2, which is currently getLastedit.eventstarttime, must be a class java.util.Date value.

According to TFM I appear to be using it correctly, unless I cannot call the field I am wanting this way. Help anyone?
468
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2008 Dec 23, 2008
The error message implies that getLastEdit.eventstarttime is not a date field. Is it?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 23, 2008 Dec 23, 2008
quote:

Originally posted by: Dan Bracuk
The error message implies that getLastEdit.eventstarttime is not a date field. Is it?



Its a time datatype, must it be a date field?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2008 Dec 23, 2008
rmorgan wrote:
>
quote:

Originally posted by: Dan Bracuk
> The error message implies that getLastEdit.eventstarttime is not a date field. Is it?

>
>
> Its a time datatype, must it be a date field?
>

No a time data type should just be a specialize datetime field that just
has zeros for the date parts.

Can you output the value just before you try and get the datepart() to
make sure you are using what you think you are getting.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2008 Dec 23, 2008
LATEST
i am with Ian on this one - output the value before applying datepart()
function to it.

if the value of eventstarttime column is NULL, cf will throw an error
because NULL is not a valid date/time object.

if the values in eventstarttime column are stored as text, then you must
enclose them in " when passing to datepart() function.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 23, 2008 Dec 23, 2008
rmorgan wrote:
>
> According to TFM I appear to be using it correctly, unless I cannot call the
> field I am wanting this way. Help anyone?
>

Two things to confirm here.

One, does the field getLastedite.eventstarttime contain a data value,
not a string that happens to look like a date to some people? I.E. is
the field in the database a date field?

Two, How are you referencing your query object? Sometimes, depending on
how one references the query, one also needs to provide a row reference.
This would look like this:

#DatePart("h",getLastEdit.eventstarttime[1])#
OR
#DatePart("h",getLastEdit['eventstarttime'][1])#
OR
#DatePart("h",getLastEdit.eventstarttime[currentRow])#
OR
#DatePart("h",getLastEdit['eventstarttime'][currentRow])#

Or something to that affect.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources