vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Brandneu! sevEingabe v3.0 - Das Eingabecontrol der Superlative!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Fortgeschrittene Programmierung
Lösung 
Autor: Thomas
Datum: 28.08.01 19:21

Hallo Leute,

Danke fürs Suchen

Die Lösung ist die Verwendung von Datumsliteralen.

Setzt man Datum in Hochkomma wie einen String ist das Format abhängig von den Ländereinstellungen. Setzt man das Datum in ## funktionierts.

Hier einige Infos aus der MSDN dazu:

Date
In Visual Basic, never type dates as strings in your code. Entering dates in code in the format #month/day/year#
ensures that the date will be interpreted correctly in any system locale. Because Visual Basic allows only English/U.S.
as a programming locale, the date will be the same to a user wherever your application is run.

For example, if a user enters 8/2/97 in an input dialog box,

CDate ("8/2/97")

returns the following results, based on the system locale:

Operating system Output
French/France 08/02/97 (= February 8, 1997)
English/U.S. 8/2/97 (= August 2, 1997)

Conversely, if you enter 8/2/97 in code,

CDate (#8/2/97#)

returns the results in the following table, based on the code locale:

Operating system Output
French/France 02/08/97 (= August 2, 1997)
English/U.S. 8/2/97 (= August 2, 1997)

If the user is in France and enters 8/2/97, the application will interpret this date as February 8, 1997,
because the date format in France is day/month/year. If a user in the United States enters the same
string, the application will understand August 2, 1997, because the date format is month/day/year.

...........................

You can use date/time literals in your code by enclosing them with the number sign (#),
in the same way you enclose string literals with double quotation marks (""). For example, you can
compare a Variant containing a date/time value with a literal date:

If SomeDate > #3/6/93# Then

Similarly, you can compare a date/time value with a complete date/time literal:

If SomeDate > #3/6/93 1:20pm# Then

If you do not include a time in a date/time literal, Visual Basic sets the time part of the value to midnight (
the start of the day). If you do not include a date in a date/time literal, Visual Basic sets the date part of
the value to December 30, 1899.

Visual Basic accepts a wide variety of date and time formats in literals. These are all valid date/time values:

SomeDate = #3-6-93 13:20#
SomeDate = #March 27, 1993 1:20am#
SomeDate = #Apr-2-93#
SomeDate = #4 April 1993#
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Umrechnung von Zeit in Sekunden seit 1.1.1970 in Datumsstrin...89Thomas28.08.01 18:28
Lösung55Thomas28.08.01 19:21

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel