10

I want to paste the current date and time to a spreadsheet and I am using the NOW() function and copy from there and paste as string but there might be a faster way. There might be an excel solution but a windows solution would be nice too becaue the problem/need isn't really excel specific.

0

8 Answers 8

11

Step 1: Open Notepad
Step 2: Hit F5
Step 3: Ctrl+A (to select all) then Ctrl+C (to copy)

1
5

Using Excel, you can use following keyboard shortcuts

  • ctrl+; enters the current date

  • ctrl+: enters the current time

Edit cudo's to @phuclv for the missing requirement

Using plain windows, you could use

  • Win+Rcmd /c date/t | clip
  • Win+Rcmd /c time /t | clip
5
  • But that doesn't copy the date to clipboard
    – phuclv
    Commented Feb 23, 2019 at 15:48
  • Also that doesn't work on my keyboard layout Commented Feb 23, 2019 at 15:56
  • Ive found a shortcut for my layout, it's ctrl+shift+; and ctrl+shitft+: (turkish-Q) Commented Feb 23, 2019 at 15:58
  • @phuclv - Enter the value and follow up with Ctr-C Commented Feb 24, 2019 at 11:25
  • 1
    To format the date, use: cmd /c "powershell -NoProfile get-date -format ^"{yyyy-MM-dd}^"|clip"
    – Bakr
    Commented Sep 20, 2022 at 21:30
4

For a system-wide solution, you can create a shortcut that will use the PowerShell's Get-Date cmdlet to retrieve the current date and copy it to the clipboard in any format desired. For example:

PS C:\> ### Default format is FullDateTimePattern
PS C:\> Get-Date

Friday, October 20, 2023 04:22:37 AM

PS C:\> ### .Net format specifier ('s' -> SortableDateTimePattern)
PS C:\> Get-Date -Format s

2023-10-20T04:31:01

PS C:\> ### A custom format string
PS C:\> Get-Date -Format yyyy-mm-dd__HH:MM:ss

2023-51-20__04:10:06

PS C:\> ### Quotes are only necessary when the format string contains spaces or special characters
PS C:\> Get-Date -Format 'yyyy-mm-dd (hh:MM:ss tt)'

2023-49-20 (04:10:33 AM)

Formatting can be specified using either pre-defined .net format specifiers or a custom formatting string. Per the online documentation:

Get-Date uses the computer's culture settings to determine how the output is formatted. To view your computer's settings, use (Get-Culture).DateTimeFormat:

PS C:\> (Get-Culture).DisplayName
English (United States)

PS C:\> (Get-Culture).DateTimeFormat | select *Pattern


FullDateTimePattern              : dddd, MMMM d, yyyy hh:mm:ss tt
LongDatePattern                  : dddd, MMMM d, yyyy
LongTimePattern                  : hh:mm:ss tt
MonthDayPattern                  : MMMM d
RFC1123Pattern                   : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern                 : M/d/yyyy
ShortTimePattern                 : h:mm tt
SortableDateTimePattern          : yyyy'-'MM'-'dd'T'HH':'mm':'ss
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern                 : MMMM yyyy

Whatever syntax you choose, use it to create a shortcut:

  1. Right-click on the Desktop > New > Shortcut.

  2. In the shortcut wizard teXtbox, contruct the target by Copying & pasting: PowerShell -NoProfile -Command "set-clipboard (Get-Date -Format <format specifier|format string>)"

  3. To eliminate window flash, Set the shortcut to run in a minimized window.

  4. Assign a shortcut key if desired (Sign out/sign in required to take effect).

Note: If used frequently in naming files or folders, the path to the shortcut can serve as a context menu command for items like:

  • HKCR\DesktopBackground\Shell
  • HKCR\Directory\Background\Shell

Drawbacks:

  • Working window loses focus.
2
  • To have a suitable format for filenames use the following: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -Command "Get-Date -Format "yyyy_MM_dd_HH_mm_ss" | set-clipboard" Output example: 2023_02_08_09_15_06
    – Sadegh
    Commented Feb 8, 2023 at 8:14
  • Interesting that Get-Date is using US-only format, not system format or a more standard ISO... To get an ISO date: powershell.exe -WindowStyle Hidden -Command "Get-Date -Format \"yyyy-MM-dd\" | set-clipboard". For file names with time I prefer a more readable form to me: powershell.exe -WindowStyle Hidden -Command "Get-Date -Format \"yyyy-MM-dd HH.mm.ss\" | set-clipboard"
    – Nux
    Commented Oct 19, 2023 at 9:40
1

This free software Phrase Express allows you to type , say #time then hits space and it will convert to say 2:08 PM or whatever you set.

It's fully customizable, you can use it with dates, emails, etc. I'm not sure if you can copy it to the clipboard without typing it out.

enter image description here

1

This AutoHotkey script worked for me, and you can edit the format.

!t::
FormatTime, time, A_now, MMddyyyyhhmm
send %time%
return

https://www.autohotkey.com/docs/commands/FormatTime.htm

1

This CopyQ command works in Linux and Window:

[Command]
Command="
    copyq:
    var time = dateString('yy-MM-dd_hhm-mss')
    copy('' + time)
    paste()"
GlobalShortcut=meta+alt+t
Icon=\xf017
Name=Paste Current Time

save the command as file and load it with F6 then load command.

for update it later you could use F6 the button Show Advanced for updating it into the GUI

more Details you find here: https://github.com/hluk/CopyQ/wiki/Command-Examples#paste-current-date-and-time

0

To answer the question, it depends which part(s) you want.

If it is just to copy to the clipboard, an executed VBS file would do it.

If it is to put the value into an Excel worksheet, an all VBA solution would suffice. When doing that, I would add the value and then set the numeric format. If you actually wanted a string, it could be: [A1] = Format(date+time, "mm/dd/yyyy hh:mm AM/PM")

1
0

There is a german software called Ac‘tivAid, a collection of AutoHotKey-Scripts which has this feature and many more in it. You can just install the software and then in it‘s menu you can assign many functions to different shortcuts. For example I use it to fill in my email and other personal stuff I need to write very often in order to reduce typing errors.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .