Unix Technical Forum

datediff is there something like it?

This is a discussion on datediff is there something like it? within the pgsql Sql forums, part of the PostgreSQL category; --> Hi all working my way through our views and all is going very well. We use datediff in MSSQL ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:52 AM
Joel Fradkin
 
Posts: n/a
Default datediff is there something like it?

Hi all working my way through our views and all is going very well.

We use datediff in MSSQL a bit and I read about the field1::date -
field2::date to return the days numerically.

Is there any way to get months and years besides guessing days / 30 for
months etc?



Joel Fradkin



Wazagua, Inc.
2520 Trailmate Dr
Sarasota, Florida 34243
Tel. 941-753-7111 ext 305



jfradkin@wazagua.com
www.wazagua.com
Powered by Wazagua
Providing you with the latest Web-based technology & advanced tools.
C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
This email message is for the use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and delete and destroy
all copies of the original message, including attachments.









Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 11:52 AM
Achilleus Mantzios
 
Posts: n/a
Default Re: datediff is there something like it?

O Joel Fradkin έγραψε στις Jan 25, 2005 :

> Hi all working my way through our views and all is going very well.
>
> We use datediff in MSSQL a bit and I read about the field1::date -
> field2::date to return the days numerically.
>
> Is there any way to get months and years besides guessing days / 30 for
> months etc?


Go to
http://www.postgresql.org/docs/7.4/i...-datetime.html
Check out smth like...

SELECT 'Achilleus is ' || date_part('years',age(timestamp '1969-01-31'))
|| ' years and ' || date_part('months',age(timestamp '1969-01-31')) || '
months old';
?column?
-----------------------------------------
Achilleus is 35 years and 11 months old
(1 row)



>
>
>
> Joel Fradkin
>
>
>
> Wazagua, Inc.
> 2520 Trailmate Dr
> Sarasota, Florida 34243
> Tel. 941-753-7111 ext 305
>
>
>
> jfradkin@wazagua.com
> www.wazagua.com
> Powered by Wazagua
> Providing you with the latest Web-based technology & advanced tools.
> C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
> This email message is for the use of the intended recipient(s) and may
> contain confidential and privileged information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the intended
> recipient, please contact the sender by reply email and delete and destroy
> all copies of the original message, including attachments.
>
>
>
>
>
>
>
>
>


--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 11:53 AM
Joel Fradkin
 
Posts: n/a
Default Re: datediff is there something like it?

Yes I am using datepart, but not seeing how with a datediff.
Maybe I just need to do the date math and put a date part on the result.
I will play around a bit when I hit one not looking for days.

Joel Fradkin

Wazagua, Inc.
2520 Trailmate Dr
Sarasota, Florida 34243
Tel. 941-753-7111 ext 305

jfradkin@wazagua.com
www.wazagua.com
Powered by Wazagua
Providing you with the latest Web-based technology & advanced tools.
© 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
This email message is for the use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and delete and destroy
all copies of the original message, including attachments.




-----Original Message-----
From: Achilleus Mantzios [mailto:achill@matrix.gatewaynet.com]
Sent: Tuesday, January 25, 2005 11:34 AM
To: Joel Fradkin
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] datediff is there something like it?

O Joel Fradkin έγραψε στις Jan 25, 2005 :

> Hi all working my way through our views and all is going very well.
>
> We use datediff in MSSQL a bit and I read about the field1::date -
> field2::date to return the days numerically.
>
> Is there any way to get months and years besides guessing days / 30 for
> months etc?


Go to
http://www.postgresql.org/docs/7.4/i...-datetime.html
Check out smth like...

SELECT 'Achilleus is ' || date_part('years',age(timestamp '1969-01-31'))
|| ' years and ' || date_part('months',age(timestamp '1969-01-31')) || '
months old';
?column?
-----------------------------------------
Achilleus is 35 years and 11 months old
(1 row)



>
>
>
> Joel Fradkin
>
>
>
> Wazagua, Inc.
> 2520 Trailmate Dr
> Sarasota, Florida 34243
> Tel. 941-753-7111 ext 305
>
>
>
> jfradkin@wazagua.com
> www.wazagua.com
> Powered by Wazagua
> Providing you with the latest Web-based technology & advanced tools.
> C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
> This email message is for the use of the intended recipient(s) and may
> contain confidential and privileged information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the

intended
> recipient, please contact the sender by reply email and delete and destroy
> all copies of the original message, including attachments.
>
>
>
>
>
>
>
>
>


--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 11:53 AM
Oleg Bartunov
 
Posts: n/a
Default Re: datediff is there something like it?

On Tue, 25 Jan 2005, Joel Fradkin wrote:

> Yes I am using datepart, but not seeing how with a datediff.
> Maybe I just need to do the date math and put a date part on the result.
> I will play around a bit when I hit one not looking for days.
>


http://www.pgsql.ru/db/pgsearch/index.html?q=datediff

> Joel Fradkin
>
> Wazagua, Inc.
> 2520 Trailmate Dr
> Sarasota, Florida 34243
> Tel. 941-753-7111 ext 305
>
> jfradkin@wazagua.com
> www.wazagua.com
> Powered by Wazagua
> Providing you with the latest Web-based technology & advanced tools.
> Ώ 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
> This email message is for the use of the intended recipient(s) and may
> contain confidential and privileged information. Any unauthorized review,
> use, disclosure or distribution is prohibited. If you are not the intended
> recipient, please contact the sender by reply email and delete and destroy
> all copies of the original message, including attachments.
>
>
>
>
> -----Original Message-----
> From: Achilleus Mantzios [mailto:achill@matrix.gatewaynet.com]
> Sent: Tuesday, January 25, 2005 11:34 AM
> To: Joel Fradkin
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] datediff is there something like it?
>
> O Joel Fradkin ?????? ???? Jan 25, 2005 :
>
>> Hi all working my way through our views and all is going very well.
>>
>> We use datediff in MSSQL a bit and I read about the field1::date -
>> field2::date to return the days numerically.
>>
>> Is there any way to get months and years besides guessing days / 30 for
>> months etc?

>
> Go to
> http://www.postgresql.org/docs/7.4/i...-datetime.html
> Check out smth like...
>
> SELECT 'Achilleus is ' || date_part('years',age(timestamp '1969-01-31'))
> || ' years and ' || date_part('months',age(timestamp '1969-01-31')) || '
> months old';
> ?column?
> -----------------------------------------
> Achilleus is 35 years and 11 months old
> (1 row)
>
>
>
>>
>>
>>
>> Joel Fradkin
>>
>>
>>
>> Wazagua, Inc.
>> 2520 Trailmate Dr
>> Sarasota, Florida 34243
>> Tel. 941-753-7111 ext 305
>>
>>
>>
>> jfradkin@wazagua.com
>> www.wazagua.com
>> Powered by Wazagua
>> Providing you with the latest Web-based technology & advanced tools.
>> C 2004. WAZAGUA, Inc. All rights reserved. WAZAGUA, Inc
>> This email message is for the use of the intended recipient(s) and may
>> contain confidential and privileged information. Any unauthorized review,
>> use, disclosure or distribution is prohibited. If you are not the

> intended
>> recipient, please contact the sender by reply email and delete and destroy
>> all copies of the original message, including attachments.
>>
>>
>>
>>
>>
>>
>>
>>
>>

>
>


Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 11:53 AM
Bruno Wolff III
 
Posts: n/a
Default Re: datediff is there something like it?

On Tue, Jan 25, 2005 at 10:11:40 -0500,
Joel Fradkin <jfradkin@wazagua.com> wrote:
> Hi all working my way through our views and all is going very well.
>
> We use datediff in MSSQL a bit and I read about the field1::date -
> field2::date to return the days numerically.
>
> Is there any way to get months and years besides guessing days / 30 for
> months etc?


The age function will give a difference in years-months in addition to
days-hours-minutes-seconds.
Depending on what you want, it may not do exactly what you want.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com