WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   SQL Frage (Date) (http://www.wcm.at/forum/showthread.php?t=108197)

Phlow 08.09.2003 19:09

SQL Frage (Date)
 
Hi

Folgendes ... habe in einer Table ein Datum (Typ Date) gespeichert, möchte zu diesem x Tage addieren und es als "datum2" in ebendieser Tabelle abspeichern (auch als Typ Date)

Geht das, wenn ja wie (möglichst ohne den Umweg über Timestamps) oder kann ich einfach 2003-12-31 + 2 machen und es kommt 2004-01-02 raus (ich bezweifel das mal *g*)

lg und vielen Dank, Phlow

pc.net 08.09.2003 19:23

funktioniert genauso, wie du beschrieben hast ... das is ja das feine an datumsfeldern ;)

willst du mal monate (bzw. jahre) addieren, so gibts (zumindest unter oracle) die add_month-funktion ...

update table_name
set datum2 = datum1 + [anzahl der tage]
where ... ;


K@sperl 08.09.2003 19:45

Bei einer MySQL Datenbank funktioniert das zwar, aber wenn bei Datum 31.12.2000 steht und man einen Tag dazuaddiert, ist das neue Datum 0.0.0000 ....

pc.net 08.09.2003 19:54

bei mysql mußt du das intervall angeben ...
http://www.mysql.com/doc/de/Date_and...s.html#IDX1256

oracle nimmt bei einer ganzzahl automatisch den wert als tag an ...

K@sperl 08.09.2003 20:00

Interessant :)
Wenn ich den Intervall nicht angebe, nimmt er auch automatisch als Einheit den Tag an, spinnt jedoch falls er über die Jahreswende kommt, mit Intervall funktionierts tadellos :)

pc.net 08.09.2003 20:06

it's not a bug - it's a feature :D:rolleyes::lol:

Phlow 08.09.2003 20:23

danke euch :-)


Alle Zeitangaben in WEZ +2. Es ist jetzt 15:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag