Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Re: [charly] extracting parts of datetime field

Quote Reply
Re: [charly] extracting parts of datetime field In reply to
Just simply create a global template like:

format_date => '

sub {
my ($value, $format) = @_;
return if (!$value);
$format ||= '%yyyy%-%mm%-%dd%';

require GT::Date;
return GT::Date::date_get($value, $format);
}

'

Now, you can use it in a template:
<%set time_formated = format_date($Launched, '%hh%:%MM%:%ss%')%>
<%if time_formated eq '00:00:00'%>
do something
<%endif%>

or:
<%set month_formated = format_date($Launched, '%mm%') %>
<%if month_formated eq '07'%>
do something
<%endif%>

Hope that helps,

TheSTone.

B.
Subject Author Views Date
Thread extracting parts of datetime field charly 4437 Jun 17, 2003, 3:20 AM
Thread Re: [charly] extracting parts of datetime field
604 4313 Jun 17, 2003, 10:41 AM
Thread Re: [TheStone] extracting parts of datetime field
charly 4290 Jun 19, 2003, 7:55 AM
Thread Re: [charly] extracting parts of datetime field
604 4284 Jun 19, 2003, 9:54 AM
Post Re: [TheStone] extracting parts of datetime field
charly 4278 Jun 19, 2003, 12:42 PM