INFORMATICS

The Best

Przełącznik języka

Zaproś mnie na KAWE

Jeżeli podoba Ci się strona i chcesz wspomóc projekt!

Postaw mi kawę na buycoffee.to

This Site

Płatnik

CMS

Hardware

Uncategorised

Emulators

Powershell

Storage Array

DNS

Antivirus program

Licznik

3.png1.png7.png2.png6.png0.png9.png
Today1102
Yesterday1012
This week7379
This month11995
Total3172609

Visitor Info

  • IP: 13.59.69.96
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

4
Online

piątek, 11 kwiecień 2025 23:20

Add date fo file name

Gwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywnaGwiazdka nieaktywna
 
 

I usually do it this way whenever I need a date/time string:

SHOW actual settings
echo %DATE%
23.11.2022
echo %time%
13:21:03,46

SET backup_file_name=%COMPUTERNAME%.%date:~6,4%-%date:~3,2%-%date:~0,2%_h_%time:~0,2%-%time:~3,2%.PGDMP

set dt=%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%__%TIME:~0,2%_%TIME:~3,2%_%TIME:~6,2% set dt=%dt: =0%

The resulting string has the format: - SrvPoint.SrvPOINT.1-23-2--20_h_11-16.PGDMP


Short explanation of how substrings work:

%VARIABLE:~num_chars_to_skip,num_chars_to_keep%

So to get just the year from a date like "23.11.2022" use:

%DATE:~6,4%
       ^-----skip 6 characters
         ^---keep 4 characters 

 

Search