Insertion time problem in sql database
CONVERT(varchar(10), getDate(),120)
Convert the time format into character format (10) Note that this is very important, and then insert it
CONVERT(nvarchar(10),count_time,121): CONVERT is a date conversion function, usually in the time type
The function used to convert between (datetime, smalldatetime) and string types (nchar, nvarchar, char, varchar) has three parameters. The first parameter refers to the size after conversion, the second parameter refers to the field or function that needs to convert the date, and the third parameter refers to the format of the conversion.
0 | 0 or 100 | mon dd yyyy hh:miAM (or PM)
1 | 101 | mm/dd/yy
2 | 102 | yy-mm-dd
3 | 103 | dd/mm/yy
4 | 104 | dd-mm-yy
5 | 105 | dd-mm-yy
6 | 106 | dd mon yy
7 | 107 | mon dd,yy
8 | 108 | hh:mm:ss
9 | 9 or 109 | mon dd yyyy hh:mi:ss:mmmmAM (or PM)
10 | 110 | mm-dd-yy
11 | 111 | yy/mm/dd
12 | 112 | yymmdd
11| 13 or 113 | dd mon yyyy hh:mi:ss:mmm(24-hour format)
14 | 114 | hh:mi:ss:mmm(24-hour format)
15 | 20 or 120 | yyyy-mm-dd hh:mi:ss(24-hour format)
16 | 21 or 121 | yyyy-mm-dd hh:mi:ss:mmm(24-hour format)
How to calculate the execution time of sql statement
The datediff function is generally used in SQL to represent the time difference.
Basic syntax:
DATEDIFF(datepart,startdate,enddate)
illustrate:
The startdate and enddate parameters are legal date expressions.
The datepart parameter can be the following values:
example:
Example 1
Use the following SELECT statement:
SELECT DATEDIFF(day,'2008-12-29','2008-12-30') AS DiffDate
result:
DiffDate
1
Example 2
Use the following SELECT statement:
SELECT DATEDIFF(day,'2008-12-30','2008-12-29') AS DiffDate
result:
DiffDate
-1
The above is the detailed content of Questions about inserting time in SQL database. For more information, please follow other related articles on the PHP Chinese website!

Some Windows 11/10 users report that they see a cmd window open up right after a Bitdefender update and it is running SecureBootEncodeUEFI.exe. This post from php.cn introduces how to remove the SecureBootEncodeUEFI.exe Trojan.

Sysdll_win64_retail.dll is a dynamic link library (DLL) file related to the FIFA 17 application. When that file gets missed or corrupted, a series of issues and errors will happen about that application. To resolve this issue, you can read this artic

Many SurfaceBook users report that they meet the “core isolation blocked by ew_usbccgpfilter.sys” issue on Windows 11/10. This post from php.cn helps to fix the annoying issue. Keep on your reading.

When you press Ctrl Alt Del on your computer, you will enter the Security Options window, where you might see Lock, Switch user, and Sign out options. Do you know that these options can be changed? This php.cn post will show you how to remove opt

Some Windows 11/10 users report that their Windows Defender has spotted a virus named Virus:Win32/Grenam.VA!MSR. But they don’t know how to remove it. This post from php.cn teaches you how to remove Virus:Win32/Grenam.VA!MSR.

When you need to visit a website frequently, it is quite troublesome to open a browser and search for it every time. Why don’t you try to save a website as an app? If you do this, you can open it as normal software. Here, php.cn offers you some usefu

Some people encountered the error code 0x00000000 on Windows 11 when they installed the latest Windows update. What should you do to cope with this unexpected error? This article on the php.cn Website will give you some clues for troubleshooting.

Are you suffering from the error message "FileType selected not supported by this app" when opening files in Teams or Excel? Now read this post from php.cn to get several useful solutions to this issue.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools