Autor Beitrag
foxy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Mi 17.09.08 11:07 
Hi Leute,

ich habe einen String in der form

YYYY-MM-DD

nun möchte ich das ich das Datum des vorherigen tages wissen.

Die frage ist wie mache ich das. Einfache string manipulation ist nicht möglich, da ja auch schaltjahre und alles berücksichtig werden müssen.
Aus dem Grund wollte ich das über DateTime machen aber weis nicht, wie ich dort sagen kann, gib mir den vorherigen tag.

Hoffe ich versteht das problem und könnt mir helfen.


Greetz
Heiko

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
bakachan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 503
Erhaltene Danke: 34

W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
BeitragVerfasst: Mi 17.09.08 11:21 
Ich glaube das was du suchst ist
ausblenden C#-Quelltext
1:
DateTime.ParseExact(string datum, string format, IFormatProvider provider);					


z.B.
ausblenden C#-Quelltext
1:
DateTime datum = DateTime.ParseExact("1988-03-10""yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);					


danach dann noch DateTime minus 1 Tag
ausblenden C#-Quelltext
1:
datum.Subtract(new TimeSpan(1000));					
foxy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Mi 17.09.08 11:23 
danke erst mal für deine antwort.
Ja die funktion der klasse habe ich auch schon entdeckt.
Aber die frage ist eher, wie ziehe ich einen Tag von dem heutigen datum ab ?


edit :

hrhr da warste ja wohl schneller :D

dank dir werde ich testen

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)


Zuletzt bearbeitet von foxy am Mi 17.09.08 11:26, insgesamt 1-mal bearbeitet
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Mi 17.09.08 11:25 
user profile iconfoxy hat folgendes geschrieben:
Aber die frage ist eher, wie ziehe ich einen Tag von dem heutigen datum ab ?

Das hat bakachan doch mit seiner letzten Code-Zeile eigentlich auch schon beantwortet. Aber dafür gibt es noch:
ausblenden C#-Quelltext
1:
datum = datum.AddDays(-1);					

Wenn es Dir wirklich um das heutige Datum geht:
ausblenden C#-Quelltext
1:
datum = DateTime.Today.AddDays(-1);					

Jürgen