Dates and Times. Slide 2 Introduction to Dates and Times (1) The DateTime data type is used to store dates and times There is a date part There is a time.

Slides:



Advertisements
Similar presentations
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
Advertisements

Reading Input from the Console eval function. variable = input("Enter a value: ") The value entered is a string. You can use the function eval to evaluate.
CSE 351 Midterm Review. Your midterm is next Wednesday Study past midterms (link on the website) Point of emphasis: Registers are not memory Registers.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
Databases Lab 5 Further Select Statements. Functions in SQL There are many types of functions provided. The ones that are used most are: –Date and Time.
Chapter 6: Using VB.NET Supplied Classes Visual Basic.NET Programming: From Problem Analysis to Program Design.
Floating Point Numbers
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
1 Values & Variables. 2 Properties of variables Should have a type Stores data Case sensitive Their names can not start with a number Reserved keywords.
Oracle9 i Datetime Functions Fresher Learning Program January, 2012.
Introduction ABAP Dates. Slide 2 Lecture Overview I go into more depth than your book about how currency and quantity values work.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Integer Data representation Addition and Multiplication.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 2 Elementary Programming.
Server-Side Scripting with JSP (2) ISYS 350. Java Array Examples of declaring an array: – int[] anArray = new int[10]; 10 elements index from 0 to 9 –
Said Salomon Unitrin Direct Insurance T-SQL Date and Time Functions Said Salomon.
Binary Arithmetic & Data representation
Extended Date/Time Format (EDTF) Ray Denenberg Library of Congress September 2015.
Formatting and Parsing. Slide 2 Introduction Two core topics Parsing - Converting strings to other types (numbers, dates, …) Formatting Converting those.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
Chapter 12: Internationalization Processing Date and Time Processing Date and Time  Locale  Date  TimeZone  Calendar and GregorianCalendar  DateFormat.
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Copyright © 2012 Pearson Education, Inc.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
Chapter 5 The String and DateTime Data Types. Class 5: String & DateTime Understand the use of characters and strings Call members of the String class.
EXPRESSION Transformation. Introduction ►Transformations help to transform the source data according to the requirements of target system and it ensures.
16 Copyright © Oracle Corporation, All rights reserved. Oracle9 i Datetime Functions.
Chapter 14 Internationalization F Processing Date and Time –Locale –Date –TimeZone –Calendar and GregorianCalendar –DateFormat and SimpleDateFormat F Formatting.
By Jariya Phongsai A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value; this.
Server-Side Scripting with JSP (2) ISYS 350. Java Array Examples of declaring an array: – int[] anArray = new int[10]; 10 elements index from 0 to 9 –
Garside, JAVA: First Contact, 2ed Java First Contact – 2 nd Edition Garside and Mariani Chapter 6 More Java Data Types.
Adding and Subtracting Mixed Numbers There are two ways to add or subtract mixed numbers. One way is to convert them into improper fractions and use the.
Notes Over 8 – 5 Add. + Add the whole numbers. Add the fractions and reduce if needed.
Controls Part 2. DateTimePicker Control Used for representing Date/Time information and take it as input from user. Date information is automatically.
Doing math In java.
Java Util Package Prepared by, S.Amudha AP/SWE. Calendar 1.The abstract Calendar class provides a set of methods that allows you to convert a time in.
5 Copyright © 2004, Oracle. All rights reserved. Managing Data in Different Time Zones.
Object-Oriented Application Development Using VB.NET 1 Chapter 4 VB.NET Programming with Supplied Classes.
CIT 383: Administrative ScriptingSlide #1 CIT 383: Administrative Scripting DateTime.
DateTime, Code Regions, and Multiple Form Applications Part13dbg.
Working with Date and Time ISYS 475. How PHP processes date and time? Traditional way: – Timestamp Newer and object oriented way: – DateTime class.
Chapter 6: Using VB.NET Supplied Classes Visual Basic.NET Programming: From Problem Analysis to Program Design.
IMS 3253: Dates and Times 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Date and Time Data Turning Strings into.
5 Copyright © 2009, Oracle. All rights reserved. Managing Data in Different Time Zones.
14 New T-SQL Functions By Sam Nasr, MCAD, MCT, MCTS NIS August 18, 2012.
14 New T-SQL Functions By Sam Nasr, MCAD, MCTS. MVP Nasr Information Systems February 8, 2014.
IS 350 Strings and Dates. Slide 2 Objectives Understand character-encoding systems and use the Char data type Use the String data type Call members of.
The Complex Number System. 1. Write each expression as a pure imaginary number. (similar to p.537 #26)
Working with Date ISYS 350.
14 Shipping Time App Using Dates and Timers
Tutorial 14 – Shipping Time Application Using DateTimes and Timers
Chapter 14 Internationalization
Do-more Technical Training
Fractions: Adding and Subtracting Like Denominators
Java String and Date ISYS 350.
JavaScript Arrays Date
JavaScript Syntax and Semantics
© 2016, Mike Murach & Associates, Inc.
14 T-SQL Functions You May Not Know
Java Date ISYS 350.
Working with DateTime Data
Phil Tayco Slide version 1.0 Created Oct 9, 2017
Packages From Deitel & Deitel.
Fractions: Adding and Subtracting Like Denominators
Java Date ISYS 350.
VBScript Session 10.
14 T-SQL Functions You May Not Know
Java Date ISYS 350.
Java Date ISYS 350.
Temporal Data Part V.
Presentation transcript:

Dates and Times

Slide 2 Introduction to Dates and Times (1) The DateTime data type is used to store dates and times There is a date part There is a time part It’s granular to 100 ns DateTimeOffset works like DateTime but stores a UTC offset The TimeSpan data type is used to store a time interval like a stopwatch You can perform arithmetic on dates and times

Slide 3 Introduction to Dates and Times (2) Use System.Convert.ToDateTime to convert a string to a date Use String.Format to format a date as a string ToString() works too

Slide 4 The DateTime Data Type (1) There constructors to create A date (year, month, day) A date and time (year, month, day, hours, minutes, seconds) A flag indicating the time zone ( DateTimeKind ) Unspecified UTC Local

Slide 5 The DateTime Data Type (2) The value is stored as a 62-bit number Number of elapsed ticks since 1/1/ bit enum containing the DateTimeKind Local, UTC, or neither When compared, ticks are compared. The DateTimeKind is ignored

Slide 6 The DateTime Data Type (Properties) Today gets the current date without the time part Now gets the current date and time (local) UtcNow gets the current date and time in UTC)

Slide 7 The DateTime Data Type (Properties) Year, Month, Day, Hour, Minute, Second give us the date and time parts DayofWeek returns an enum DayOfYear returns the value of the same name

Slide 8 The DateTimeOffset Data Type Similar to the DateTime data type The constructor takes a TimeSpan argument containing the UTC offset Properties Now gives us the current local time and UTC offset UtcNow adds the UTC offset

Slide 9 Time Zones (1) Your computer knows which time zone it’s in

Slide 10 Time Zones (2) The System.TimeZone class represents a time zone CurrentTimeZone get the time zone of the local computer StandardName returns the name of the time zone DaylightName returns the name of the daylight time zone

Slide 11 Time Zones (3)

Slide 12 Date Arithmetic Call AddYears, AddMonths, AddDays, AddHours, AddMinutes, AddSeconds on a date to add the interval units Negative values subtract the incremental unit Example: currentDate = currentDate.AddHours(hours); currentDate = currentDate.AddMinutes(minutes); currentDate = currentDate.AddSeconds(seconds);

Slide 13 The TimeSpan Data Type The TimeSpan data type represents a time interval Elapsed hours, minutes, seconds… It’s much like a stopwatch You can Subtract two dates giving a TimeSpan Add a timespan to a date giving a timespan Add and subtract two timespans

Slide 14 TimeSpan Constructors The following constructors create a TimeSpan :

Slide 15 TimeSpan Properties Days, Hours, Minutes, Seconds, Milliseconds, Ticks get the number of whole intervals in the time period TotalDays, TotalHours, TotalMinutes, TotalSeconds, TotalMilliseconds, TotalTicks get the number of whole and fractional intervals in the time period 1:30 is expressed as 1.5 hours

Slide 16 Date Arithmetic using TimeSpans Add a TimeSpan to a date: int hours, minutes, seconds; TimeSpan span = new TimeSpan(hours, minutes, seconds); currentDate = currentDate.Add(span); Subtract a TimeSpan from a date currentDate = currentDate.Subtract(span);