DateTime
No edit summary
(Updated Edited template to July 12, 2025.)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''DateTime.Now''' returns the current date and time
To create a Datetime for a specific date use:
To create a Datetime for a specific date use:
  DateTime.Parse('2020-01-01')
  DateTime.Parse('2020-01-01')
Line 5: Line 7:


===== Empty DateTime that is not nullable =====
===== Empty DateTime that is not nullable =====
A DateTime that is not nullable, i.e. a '''DateTime''' not a '''DateTime?''' without a date, what value does it have?
A DateTime that is not nullable, i.e. a '''DateTime,''' not a '''DateTime?''' Without a date, what value does it have?


You can create a value using, which will be an empty:  
You can create a value using - which will be empty:  
  DateTime.Create(1, 1, 1)
  DateTime.Create(1, 1, 1)
You can also compare an empty DateTime value with this empty DateTime value like this:
You can also compare an empty DateTime value with this empty DateTime value like this:
Line 13: Line 15:
It will return true for an empty but not nullable DateTime variable.  
It will return true for an empty but not nullable DateTime variable.  
[[Category:OCL]]
[[Category:OCL]]
{{Edited|July|12|2025}}

Latest revision as of 05:48, 20 January 2025

This page was created by Lars.olofsson@mdriven.net on 2020-10-09. Last edited by Edgar on 2025-01-20.

DateTime.Now returns the current date and time

To create a Datetime for a specific date use:

DateTime.Parse('2020-01-01')

or

DateTime.Create(2020, 1, 1)
Empty DateTime that is not nullable

A DateTime that is not nullable, i.e. a DateTime, not a DateTime? Without a date, what value does it have?

You can create a value using - which will be empty:

DateTime.Create(1, 1, 1)

You can also compare an empty DateTime value with this empty DateTime value like this:

vDateTimeValue = DateTime.Create(1, 1, 1) 

It will return true for an empty but not nullable DateTime variable.